package com.ywjh.inter.service;

import java.sql.Connection;

import com.ywjh.inter.conn.DBConnection;
import com.ywjh.inter.dao.InsulinPenSysMsgDAO;
import com.ywjh.inter.entity.InsulinPenSysMsgEntity;

public class InsulinPenSysMsgService {
	
	private static InsulinPenSysMsgService instance;
	private InsulinPenSysMsgDAO insulinPenSysMsgDAO;
	
	public static InsulinPenSysMsgService getInstance() {
		if(instance == null) {
			instance = new InsulinPenSysMsgService();
			instance.insulinPenSysMsgDAO = new InsulinPenSysMsgDAO();
		}
		return instance;
	}

	public boolean add(InsulinPenSysMsgEntity entity) {
		boolean b = false;
		Connection conn = null;
		try {
			conn = DBConnection.getDBConnection();
			b = insulinPenSysMsgDAO.insert(conn, entity);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			DBConnection.close(conn);
		}
		return b;
	}
	
	public InsulinPenSysMsgEntity getNewBySn(String sn) {
		InsulinPenSysMsgEntity b = null;
		Connection conn = null;
		try {
			conn = DBConnection.getDBConnection();
			b = insulinPenSysMsgDAO.getNewBySn(conn, sn);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			DBConnection.close(conn);
		}
		return b;
	}
}
